#include <stdio.h>
#include <assert.h>
#include "vector3d.h"

void test_vector3d() {
    printf("=== 测试 Vector3D ===\n");
    
    // 测试创建
    Vector3D v1 = vector3d_create(1.0, 2.0, 3.0);
    assert(v1.x == 1.0 && v1.y == 2.0 && v1.z == 3.0);
    
    // 测试加法
    Vector3D v2 = vector3d_create(4.0, 5.0, 6.0);
    Vector3D sum = vector3d_add(v1, v2);
    assert(sum.x == 5.0 && sum.y == 7.0 && sum.z == 9.0);
    
    // 测试点积
    double dot = vector3d_dot(v1, v2);
    assert(dot == 32.0);
    
    // 测试叉积
    Vector3D cross = vector3d_cross(v1, v2);
    assert(cross.x == -3.0 && cross.y == 6.0 && cross.z == -3.0);
    
    // 测试归一化
    Vector3D norm = vector3d_normalize(v1);
    double mag = vector3d_magnitude(norm);
    assert(fabs(mag - 1.0) < 1e-6);
    
    printf("所有Vector3D测试通过！\n");
}

int main() {
    test_vector3d();
    return 0;
}
